import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
const path = require('path');

// https://vitejs.dev/config/
export default defineConfig(prop => {
  return {
    plugins: [vue()],
    base: prop.mode === 'prod'? './': './',
    build: {
      assetsDir: 'static',
    },
    resolve: {
      alias: {
        '@': path.join(__dirname, './src')
      },
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@import "./src/assets/css/mixin.scss";`
        }
      }
    },
    server: {
      host: '0.0.0.0',
      port: 3000,
      https: false,
      open: false, //启动时是否自动在浏览器打开，值为字符串时，会被用作 URL 的路径名。
      proxy: {
        '/webApi': {
          target: 'http://localhost:9508/xqc_api/v1.0/',
          ws: false,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/webApi/, '')
        }
      }
    }
  }
})
